package ru.dc.gui.swing.util;

import org.apache.commons.io.FileUtils;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;
import java.util.ResourceBundle;

/**
 * <pre>
 * User: Penkov Vladimir
 * Date: 02.11.2010
 * Time: 18:27:32
 * </pre>
 */
public class LocalizedTableCellRenderer extends DefaultTableCellRenderer  {
    private ResourceBundle rb;

    public LocalizedTableCellRenderer() {
        rb = ResourceBundle.getBundle("locale/messages");
    }

    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

        String str = value.toString();
        if (rb.containsKey(str)) {
            label.setText(rb.getString(str));
        }

        return label;
    }

}
